package com.question.business.role.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.question.business.role.entity.RoleMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 角色菜单Mapper接口
 *
 * @author star
 * @since 2023-09-13
 */
@Mapper
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {

    /**
     * 角色菜单查询
     *
     * @param roleId 角色ID
     * @return List<String> 响应参数
     */
    @Select("SELECT menu_id FROM t_role_menu WHERE role_id = #{typeId}")
    List<String> queryRoleMenuList(String roleId);

    /**
     * 根据角色ID删除菜单
     *
     * @param roleId 角色ID
     */
    @Delete("DELETE FROM t_role_menu WHERE role_id = #{roleId}")
    void deleteByRoleId(String roleId);

    /**
     * 角色菜单接口是否授权
     *
     * @param roles 角色ID
     * @param url   菜单接口
     * @return Integer
     */
    Integer selectCountByRoleOrInterface(List<String> roles, @Param("url") String url);
}